

// 图片地址是否服务器判断
export const imgUrlDev = (url) => {
    if (url === 'system_message') {
        return (process.env.NODE_ENV === 'development') ? `/api/static/img/system_avator/system_message.jpg` : `static/img/system_avator/system_message.jpg`
    }
    return (process.env.NODE_ENV === 'development') ? `/api/static/${url}` : `static/${url}`
}
// 设置token
export const setToken = (key, value) => localStorage.setItem(key, value);
// 获取token
export const getToken = key => localStorage.getItem(key);
// 移除token
export const removeToken = key => localStorage.removeItem(key);
// 去除字符右边空格
export const RTrim = str => {
    return str.replace(/(\s*$)/g, "");
}
// 节流 time毫秒
export const throttle = (callback, time, ...args) => {
    let fri = new Date().getTime();
    return function() {
        
        let now = new Date().getTime();
        if (now - fri < time) {
            return;
        }
        fri = now;
        callback(...arguments, ...args);
    }
}
export const replaceHighLigh = (str, highLight) => {
    // 为需要高亮的字符包裹元素
    if (!highLight) return str;
    return str.replace(highLight, (`<span class="highLightSpan">${highLight}</span>`))
}
